Improve/archived object map aws error#3147
Conversation
When objects are transitioned to archived storage classes (e.g. GLACIER, ARCHIVE_FR, COLD_ARCHIVE) via lifecycle rules, S3-compatible backends return an InvalidObjectState error on GetObject/HeadObject instead of the usual NoSuchKey. Previously this was not handled, causing sandbox creation to fail with a generic 'Internal' gRPC error. Now: - Added ErrObjectArchived sentinel error in storage package - AWS storage provider maps InvalidObjectState to ErrObjectArchived in WriteTo, OpenRangeReader, and Size methods - Orchestrator returns a clear FailedPrecondition error telling users to rebuild the template when sandbox files are archived - Metrics track archived objects as a distinct 'archived' outcome
Consolidate AWS error-to-sentinel mapping into a single mapAWSError() function, replacing duplicated InvalidObjectState/NoSuchKey/NotFound checks across WriteTo, OpenRangeReader, and Size methods. This also fixes an inconsistency where Size() checked types.NotFound but WriteTo() and OpenRangeReader() did not.
There was a problem hiding this comment.
Code Review
This pull request introduces support for identifying and handling archived storage objects that cannot be directly read. It defines a new sentinel error ErrObjectArchived, maps AWS S3 InvalidObjectState errors to this sentinel, and updates the orchestrator's sandbox creation logic to return a failed precondition error when encountering archived files. There are no review comments, and we have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd994b7b92
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if errors.Is(err, storage.ErrObjectArchived) { | ||
| telemetry.ReportError(ctx, "sandbox files archived", err, telemetry.WithSandboxID(req.GetSandbox().GetSandboxId())) | ||
|
|
||
| return nil, status.Errorf(codes.FailedPrecondition, "sandbox files for '%s' are archived and not directly accessible, please rebuild the template", req.GetSandbox().GetSandboxId()) |
There was a problem hiding this comment.
Handle archived metadata before resuming
When the archived object is the template metadata blob, template.Metadata() above returns the ErrObjectArchived produced by awsObject.WriteTo, but this new check only runs after RebootSandbox/ResumeSandbox return an error. That path exits earlier with failed to read template metadata instead of the new FailedPrecondition rebuild response, so archived templates whose metadata object is in GLACIER still surface as a generic Create failure.
Useful? React with 👍 / 👎.
refactor: extract mapAWSError helper to reduce duplication
Consolidate the duplicated AWS error → sentinel mapping across WriteTo, OpenRangeReader, and Size into a single mapAWSError() helper function.
This also fixes an inconsistency where Size() checked types.NotFound but the other two methods did not.
Changes: 1 file, +23 -34 (net reduction of 11 lines)